package com.pfsoft.grpcserver.common.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @author pengfei
 * @date 2022年07月11日 12:01
 */

@Component
@Aspect
@Slf4j
public class LogAop {

    @Pointcut("execution(public * com.pfsoft.grpcserver.controller..*(..))")
    public void controlCutPoint() {}

    @Before("controlCutPoint()")
    public void beforeMethod(JoinPoint joinPoint){
// 接收到请求，记录请求内容
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();

    }



}
